<?php


require 'database.php';

$base=new Db;


$page=$_POST['page'];



$id=$_POST["id"];
if($id){
    $__delid__=$base->doSql('select * from ey_images_upload where img_id="'.$id.'"');
    $__delid__=$__delid__[0];
    
    unlink('..'.$__delid__["image_url"]);
    
    $base->doSql('delete from ey_images_upload where img_id="'.$id.'"');
}

if($page){
    
    
    $__page__=(($page-1)*10);
    if($tid){
        $data=$base->doSql('select * from ey_images_upload  limit '.$__page__.',10');
    
    
        $count=$base->doSql('select * from ey_images_upload  ');
    }else{
        $data=$base->doSql('select * from ey_images_upload  limit '.$__page__.',10');
    
    
        $count=$base->doSql('select * from ey_images_upload  ');
    }
    
    
    for ($i = 0; $i < count($data); $i++) {
        
        
        $data[$i]["add_time"]=date('Y-m-d' , $data[$i]["add_time"]);
        
    }


}elseif(!$page && !$text){
    
    $data=$base->doSql('select * from ey_images_upload  limit 0,10');


    $count=$base->doSql('select * from ey_images_upload  ');
    
    
    
    for ($i = 0; $i < count($data); $i++) {
        
        $data[$i]["add_time"]=date('Y-m-d' , $data[$i]["add_time"]);
        
    }
}

$__data=[
    "total"    =>count($count),
    "data"=>$data,
    "select"=>$___search___?1:0
];

return json($__data);